<?php 
session_start();
if (isset($_POST['name']) && isset($_SESSION['openid'])){
	$name=trim(addslashes($_POST['name']));
	$phone=trim(addslashes($_POST['phone']));
	$hao=trim(addslashes($_POST['hao']));
	include_once("../c/config.php");
	$mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
	if (!$mysqli->set_charset("utf8")) {printf("Error loading character set utf8: %s\n", $mysqliTwo->error);}
	$openid=$_SESSION['openid'];
	$query=$mysqli->query("select id from users where openid='".$openid."' limit 0, 1");
	if($query->num_rows>0){
	    $userInfo=$query->fetch_array();
	    $query=$mysqli->query("select id from u3 where openid='".$openid."' limit 0, 1");
	    if($query->num_rows>0){
	    	$mysqli->query("update u3 set name='".$name."',phone='".$phone."' where openid='".$openid."' ");
	    }else{  
	    	$mysqli->query("insert into u3(openid,name,phone,hao,createtime) values('".$openid."','".$name."','".$phone."','".$hao."','".date("Y-m-d H:i:s")."') ");
	    }
	}
	echo json_encode(array('status'=>'ok'));
}
?>